import time
from lxml import html

import ddddocr
ocr = ddddocr.DdddOcr()

from src.verification_captcha import get_select_id, get_img_code, get_target_code, \
    get_css_properties

if __name__ == '__main__':
    with open('captcha.html', 'r') as file:
        content = file.read()

    start_time = time.time()
    tree = html.fromstring(content)
    style_tags = tree.xpath('//style')
    z_index_map, empty_map = get_css_properties(style_tags[0].text)
    target_code = get_target_code(tree, z_index_map)
    # print(target_code)
    ids = get_img_code(tree, empty_map)
    select_ids = get_select_id(tree, ids, target_code)
    end_time = time.time()
    print(f'解析时间2: {end_time - start_time} 秒')
    print(ids)
    print(select_ids)
